package com.cssl.controller;

import com.cssl.domain.DtsCategory;
import com.cssl.domain.dto.DtsCategoryDto;
import com.cssl.openFeign.CategoryFeignClient;
import com.cssl.util.InfoCode;
import com.cssl.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
import java.util.List;
@RestController
@RequestMapping("/category")
@Api(value = "分类接口",tags = "商品分类相关操作")
public class CategoryController {

    @Autowired
    private CategoryFeignClient client;

    /**
     *
     * @param map
     * id
     * @return
     */
    @PostMapping("/getLevel2")
    public Result getLevel2(@RequestBody Map map){
      return client.getLevel2(map);
    }

    @PostMapping("/getCategory")
    public Result getCategory(@RequestBody Map map){
        return client.getCategory(map);
    }

    @PostMapping("/getL1AndL2")
    @ApiOperation(value = "获取一级分类及对应的二级分类")
    public Result getL1AndL2(){
        return  client.getL1AndL2();
    }


    @PostMapping("/clickL1GetL2")
    @ApiOperation(value = "获取选中的一级分类及二级分类")
    public Result clickL1GetL2(@RequestBody DtsCategory category){
        return  client.clickL1GetL2(category);
    }

    @PostMapping("/getLevel2AndCheckedL2")
    @ApiOperation(value = "获取选中的二级分类及选中的二级分类", notes = "id")
    public Result getLevel2AndCheckedL2(@RequestBody DtsCategory category){
        return client.getLevel2AndCheckedL2(category);
    }

    @PostMapping("/list")
    Result dtsorderlist(@RequestBody DtsCategoryDto dtsCategoryDto){
        return client.dtsorderlist(dtsCategoryDto);
    }
    @DeleteMapping("/delete")
    Result categorydelete(@RequestParam("ids") String ids){
        return client.categorydelete(ids);
    }
    @PostMapping("/updatecategory")
    Result updatecategory(@RequestBody Map updatecategory){
        return  client.updatecategory(updatecategory);
    }
    @PostMapping("/addcategory")
    Result addcategory(@RequestBody Map addcategory){
        return  client.addcategory(addcategory);
    }
}
